#include "mainwindow.h"
#include <QApplication>
#include <QFont>
#include <QSharedMemory>
#include <fstream>

int main(int argc, char *argv[])
{
    QApplication a(argc, argv);
    QFont font("楷体",20,QFont::Bold);
    //
    fstream file("./ModelToolPlugin.qss",ios::in);
    if (!file)
    {
        qDebug() << "Error opening file.";
    }
    else{
        std::string sQss((istreambuf_iterator<char>(file)),istreambuf_iterator<char>());
        a.setStyleSheet(sQss.c_str());
        file.close();
    }
    //
    //a.setFont(font);
    setlocale(LC_ALL,"");
    bindtextdomain("fsapp","locale");
    textdomain("fsapp");

    static QSharedMemory *singleApp = new QSharedMemory("SingleApp");//创建“SingleApp”的共享内存块
    if(!singleApp->create(1))//创建失败，说明已经有一个程序运行，
    {
        QMessageBox::information(NULL,_("tips"),_("The program is already running"));//弹出提示框 注意：该提示应该在 qApp->quit();之前，否则提示框将会一闪而过
        qApp->quit();//退出当前程序
        return -1;
    }

/*
    std::string statusInfo;
    int year, month, day;
    int nCheck = initialLDK(1060, statusInfo, year, month, day);
    if(nCheck!=0)
    {
        MSGINF::MsgShowOk(nullptr,_("Critical"),_("Dongle error, please confirm that the dongle is inserted or contact the manufacturer to resolve it"));
        return 0;
    }

*/
    MainWindow w;
    w.show();
    w.showMaximized();
    //w.setFixedSize(600,400);    //设置窗体为固定的大小，防止用户通过拖拽改变其大小
    return a.exec();
}
